jQuery(document).ready(function($){

	//css support
	$('ul.col-2 li:nth-child(2n+2),ul.col-3 li:nth-child(3n+3),ul.col-4 li:nth-child(4n+4),ul.col-5 li:nth-child(5n+5),ul.col-6 li:nth-child(6n+6),ul.col-7 li:nth-child(7n+7)').css('margin-right','0');
	$('ul.col-2 li:nth-child(2n+2),ul.col-3 li:nth-child(3n+3),ul.col-4 li:nth-child(4n+4),ul.col-5 li:nth-child(5n+5),ul.col-6 li:nth-child(6n+6),ul.col-7 li:nth-child(7n+7)').addClass('nomargin');


    //banner slide
    $('.banner').flexslider({
        selector: ".slidese > li",
        animation: "fade",
        controlNav: true,
        multipleKeyboard:true,
        animationLoop: true,
        directionNav: false,
        slideshow: true,
        slideshowSpeed: 6000,
        easing:"swing",
        smoothHeight: false,
        pauseOnAction:true,
        pauseOnHover:true,
        start: function(slider){
            //$('#loader').remove();
        },
        after: function(slider){
            //
        }
    });


	$("ul.eachnav").each(function(){
		$(this).find("li").each(function(i){
			if(i == 1){
                $(this).addClass("each-subnav1");
            }else{
                $(this).addClass("each-subnav" + i);
            }
		});
    });	


	$(function() {
            //文字轮播
            $(".li-list li:eq(0)").clone(true).appendTo($(".li-list")); //克隆第一个放到最后(实现无缝滚动)
            var liHeight = $(".message-list").height(); //一个li的高度
            //获取li的总高度再减去一个li的高度(再减一个Li是因为克隆了多出了一个Li的高度)
            var totalHeight = ($(".li-list li").length * $(".li-list li").eq(0).height()) - liHeight;
            $(".li-list").height(totalHeight); //给ul赋值高度
            var index = 0;
            var autoTimer = 0; //全局变量目的实现左右点击同步
            var clickEndFlag = true; //设置每张走完才能再点击
            function tab() {
                $(".li-list").stop().animate({
                    top: -index * liHeight
                },
                400,
                function() {
                    clickEndFlag = true; //图片走完才会true
                    if (index == $(".li-list li").length - 1) {
                        $(".li-list").css({
                            top: 0
                        });
                        index = 0;
                    }
                })
            }
            function next() {
                index++;
                if(index > $(".li-list li").length - 1) {//判断index为最后一个Li时index为0
                    index = 0;
                }
                tab();
            }
            //自动轮播
            autoTimer = setInterval(next, 4000);
            $(".li-list a").hover(function() {
                clearInterval(autoTimer);
            },
            function() {
                autoTimer = setInterval(next, 4000);
            })
            //结束
        })

	// css3动画
	new WOW().init();
});
